//
//  ShanghaiNightsVC.m
//  SHShopping
//
//  Created by 坤鼎 on 2019/8/30.
//  Copyright © 2019 kunding. All rights reserved.
//

#import "ShanghaiNightsVC.h"

#import "ShanghaiNightsVC.h"
#import "FiveBtnView.h"
#import "PublicRightImageCell.h"
#import "PublicThreeImageCell.h"
#import "DiscoverTableViewCell.h"
#import "ShanghaiNightsScrollView.h"
#import "ListNightSHTweetModel.h"
#import "ListNightSHImgModel.h"
#import "FiveBtnMoreViewController.h"
#import "MPMoviePlayerVC.h"

@interface ShanghaiNightsVC () <UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) UIView *topNavView;
@property (nonatomic, strong) UIButton *navBackBtn;
@property (nonatomic, strong) UILabel *navTitle;

@property (nonatomic, strong) UIView *tableHeaderView;
@property (nonatomic, strong) UIView *topView;
@property (nonatomic, strong) FiveBtnView *fiveBtnView;
@property (nonatomic, strong) UIView *mapView;
/**
 推文，最下方   listNightSHTweet
 */
@property (nonatomic, strong) NSMutableArray *tableViewDataArr;
/**
 夜上海专线
 */
@property (nonatomic, strong) NSMutableArray *listNightSHImgArr;
/**
 夜上海专栏
 */
@property (nonatomic, strong) NSMutableArray *listNightSHSpecialArr;




@property (nonatomic, assign) NSInteger refreshCount;//上滑次数
@property (nonatomic, assign) NSInteger totalCount;//列表个数


@property (nonatomic, strong) UIImageView *image2;
@property (nonatomic, strong) UIImageView *image3;
@property (nonatomic, strong) ShanghaiNightsScrollView *scrollView;
@property (nonatomic, strong) UILabel *lbTitle;//当前控制器抬头
@property (nonatomic, strong) ListNightSHTweetModel *shareDataModel;



@end

@implementation ShanghaiNightsVC

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:YES];
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [self.navigationController setNavigationBarHidden:NO];
}

/// 状态栏颜色
- (UIStatusBarStyle)preferredStatusBarStyle {
    return UIStatusBarStyleLightContent;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self createTopView];
   
    [self.view addSubview:self.tableView];
    
    [self addNav];
    
    // 添加头部的下拉刷新
    MJRefreshNormalHeader *header = [[MJRefreshNormalHeader alloc] init];
    [header setRefreshingTarget:self refreshingAction:@selector(headerClick)];
    self.tableView.mj_header = header;
    [header beginRefreshing];
    
    // 添加底部的上拉加载
    MJRefreshBackNormalFooter *footer = [[MJRefreshBackNormalFooter alloc] init];
    [footer setRefreshingTarget:self refreshingAction:@selector(footerClick)];
    self.tableView.mj_footer = footer;
    
    self.tableView.rowHeight = UITableViewAutomaticDimension; // 自适应xib高度
    self.tableView.estimatedRowHeight = 200; //先估计一个高度
}

- (void)createTopView {
    self.topView = [[UIView alloc] init];
    //顶部Nav背景图
    //顶部背景图
    self.image2 = [[UIImageView alloc] initWithFrame:CGRectMake(0, -kStatusBarHeight, SCREEN_WIDTH, ADAPT_W(240))];
    //圆角图
    self.image3 = [[UIImageView alloc] initWithFrame:CGRectMake(ADAPT_W(16), ADAPT_W(112) - kStatusBarHeight, SCREEN_WIDTH - ADAPT_W(32), ADAPT_W(180))];
    self.image3.backgroundColor = [UIColor whiteColor];
    self.image3.layer.cornerRadius = 10;//圆角
    self.image3.layer.masksToBounds = YES;
    self.image2.image = LHYPlaceholderImage;
    self.image3.image = LHYPlaceholderImage;

    [self.topView addSubview:self.image2];
    [self.topView addSubview:self.image3];
    self.topView.frame = CGRectMake(0, 0, SCREEN_WIDTH, GetViewYH(self.image3));
    
    DRNRealTimeBlurView *blurView2 = [[DRNRealTimeBlurView alloc] initWithFrame:self.image2.bounds];
    [self.image2 addSubview:blurView2];
}

// 头部的下拉刷新触发事件
- (void)headerClick {
    
    self.refreshCount = 1;
    [self loadNetData];
    // 结束刷新
    [self.tableView.mj_header endRefreshing];
}
// 底部的上拉加载触发事件
- (void)footerClick {
    self.refreshCount++;
    [self addData];
}

- (void)addNav {
    UIView *navView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, kNavBarAndStatusBarHeight + 20)];
    self.topNavView = navView;
    [self.view addSubview:navView];
    navView.backgroundColor = [UIColor whiteColor];
    
    UIButton *backBtn = [[UIButton alloc] initWithFrame:CGRectMake(16, kNavBarAndStatusBarHeight - ADAPT_W(30), 34, 34)];
    self.navBackBtn = backBtn;
    [backBtn setImage:ImageNamed(@"navigationBar_popBack") forState:UIControlStateNormal];
    [backBtn addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
    [navView addSubview:backBtn];
    
    UILabel *lbTitle = [[UILabel alloc] initWithFrame:CGRectMake((SCREEN_WIDTH - 80)/2, kNavBarAndStatusBarHeight - ADAPT_W(30), 80, 34)];
    self.navTitle = lbTitle;
    lbTitle.font = FONT_BOLD(19);
    lbTitle.textColor = [UIColor whiteColor];
    lbTitle.textAlignment = 1;
    [navView addSubview:lbTitle];
}

- (void)backAction {
    [super backAction];
}

- (void)loadNetData {
    [SXLoadingView showProgressHUD:nil];
    if (self.tableViewDataArr.count != 0) {
        [self.tableViewDataArr removeAllObjects];
    }

    [PPNetworkHelper POST:URL_nightshInit parameters:nil success:^(id responseObject) {
        [SXLoadingView hideProgressHUD];

        NSDictionary *dataDic = [[NSDictionary alloc] init];
        dataDic = responseObject[@"retBody"];
        self.tableViewDataArr = [ListNightSHTweetModel arrayOfModelsFromDictionaries:dataDic[@"listNightSHTweet"] error:nil];
        self.listNightSHImgArr = dataDic[@"listNightSHImg"];
        self.listNightSHSpecialArr = dataDic[@"listNightSHSpecial"];
    
        
        [self.fiveBtnView updateFiveBtnViewWith:self.listNightSHImgArr];
        self.fiveBtnView.lbTitle.text = [NSString stringWithFormat:@"%@", DSStringValue(dataDic[@"nightSHTopNav"][0][@"title"])];
        self.fiveBtnView.lbDetailTitle.text = [NSString stringWithFormat:@"%@", DSStringValue(dataDic[@"nightSHTopNav"][0][@"presentation"])];
        [self.image2 sd_setImageWithURL:[NSURL URLWithString:DSStringValue(dataDic[@"nightSHTopNav"][0][@"imgPath"])] placeholderImage:LHYPlaceholderImage];
        [self.image3 sd_setImageWithURL:[NSURL URLWithString:DSStringValue(dataDic[@"nightSHTopNav"][0][@"imgPath"])] placeholderImage:LHYPlaceholderImage];
        self.navTitle.text = DSStringValue(dataDic[@"nightSHTopNav"][0][@"navName"]);
        [self.scrollView updateShanghaiNightsScrollViewWith:self.listNightSHSpecialArr];
        
        [self.tableView reloadData];
        self.tableView.tableHeaderView = self.tableHeaderView;

    } failure:^(NSError *error) {
        [SXLoadingView showAlertHUD:SXLoadingErrorStr duration:SXLoadingErrorTime];
    }];
}

- (void)addData {
    NSDictionary *par = @{@"page":@(self.refreshCount),
                          @"pageSize":@"5"
                          };
    [PPNetworkHelper POST:URL_nightshNext parameters:par success:^(id responseObject) {
        NSArray *arr = responseObject[@"retBody"][@"rows"];
        self.totalCount = [responseObject[@"retBody"][@"total"] integerValue];
        if (IsNotNilArr(arr)) {
            NSArray *modelArr = [ListNightSHTweetModel arrayOfModelsFromDictionaries:arr error:nil];
            [self.tableViewDataArr addObjectsFromArray:modelArr];
        }
        [self.tableView reloadData];
    } failure:^(NSError *error) {
        [SXLoadingView showAlertHUD:SXLoadingErrorStr duration:SXLoadingErrorTime];
    }];
}
#pragma mark - 友盟分享
- (void)shareAction:(UIButton *)sender {
    self.shareDataModel = self.tableViewDataArr[sender.tag - 1000];
    
    [self shareAlertView];
    //    友盟原生UI面板
    {
        //        [UMSocialUIManager setPreDefinePlatforms:@[
        //                                                   @(UMSocialPlatformType_QQ),
        //                                                   @(UMSocialPlatformType_WechatSession),
        //                                                   @(UMSocialPlatformType_UserDefine_Begin + 1)]];
        //        [UMSocialUIManager showShareMenuViewInWindowWithPlatformSelectionBlock:^(UMSocialPlatformType platformType, NSDictionary *userInfo) {
        //            // 根据获取的platformType确定所选平台进行下一步操作
        //            [self shareWebPageToPlatformType:platformType dic:dic];
        //        }];
    }
}

- (void)shareAlertView {
    UIWindow *window = [[UIApplication sharedApplication] keyWindow];
    //    蒙板
    UIView *view = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    view.tag = 9998;
    view.backgroundColor = [UIColor colorWithWhite:0 alpha:0.7];
    [window addSubview:view];
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapRemoveShareView:)];
    [view addGestureRecognizer:tap];
    
    
    UIView *whiteView = [[UIView alloc] initWithFrame:CGRectMake(16, SCREEN_HEIGHT - 120 - 28, SCREEN_WIDTH - 32, 120)];
    whiteView.backgroundColor = [UIColor whiteColor];
    whiteView.tag = 9999;
    ViewBorderRadius(whiteView, 10, 0, [UIColor whiteColor]);
    [window addSubview:whiteView];
    
    //间距
    float weight = 65;
    int range = (whiteView.frame.size.width - weight * 4) / 5;
    NSArray *arr = @[@"微信",
                     @"朋友圈",
                     @"QQ"];
    
    for (int i = 0; i < arr.count; i++) {
        UIButton *imageBtn = [[UIButton alloc] initWithFrame:CGRectMake(range + i * (weight + range), 20, weight, weight)];
        [imageBtn setImage:[UIImage imageNamed:[NSString stringWithFormat:@"分享%d", i]] forState:UIControlStateNormal];
        [imageBtn addTarget:self action:@selector(shareBtnAction:) forControlEvents:UIControlEventTouchUpInside];
        imageBtn.tag = i + 10000;
        [imageBtn setTitle:arr[i] forState:UIControlStateNormal];
        [whiteView addSubview:imageBtn];
        
        UILabel *lb = [[UILabel alloc] initWithFrame:CGRectMake(range + i * (weight + range), GetViewYH(imageBtn), weight, 17)];
        lb.tag = i + 10010;
        lb.textColor = UIColorFromRGB(0x333333);
        lb.font = FONT(12);
        lb.text = arr[i];
        lb.textAlignment = 1;
        [whiteView addSubview:lb];
    }
    //    if (![QQApiInterface isQQInstalled]) {//没有安装QQ
    //        UIButton *btn = [whiteView viewWithTag:10002];
    //        btn.hidden = YES;
    //
    //        UILabel *lb = [whiteView viewWithTag:10012];
    //        lb.hidden = YES;
    //    }
    //    if (![WXApi isWXAppInstalled]) { //没有安装微信
    //        UIButton *btn0 = [whiteView viewWithTag:10000];
    //        UIButton *btn1 = [whiteView viewWithTag:10001];
    //        btn0.hidden = YES;
    //        btn1.hidden = YES;
    //
    //        UILabel *lb0 = [whiteView viewWithTag:10010];
    //        UILabel *lb1 = [whiteView viewWithTag:10011];
    //        lb0.hidden = YES;
    //        lb1.hidden = YES;
    //    }
}

- (void)shareBtnAction:(UIButton *)sender {
    [self removeShareView];
    NSInteger platformType = 0;
    switch (sender.tag) {
            case 10000: {
                platformType = 1;//微信聊天
            }
            break;
            case 10001: {
                platformType = 2;//微信朋友圈
            }
            break;
            case 10002: {
                platformType = 4;//QQ聊天
            }
            break;
            case 10003: {
                if ([UserManager sharedUserManager].isLogin) {
                    NSString *str = [NSString stringWithFormat:@"%@", self.shareDataModel.id];
                    NSDictionary *par = @{@"userId":DSStringValue([UserManager sharedUserManager].userInfo.uid),
                                          @"tweetId":str
                                          };
                    
                    [PPNetworkHelper POST:URL_addCollect parameters:par success:^(id responseObject) {
                        [SXLoadingView showAlertHUD:responseObject[@"retMsg"] duration:SXLoadingTime];
                    } failure:^(NSError *error) {
                        [SXLoadingView showAlertHUD:SXLoadingErrorStr duration:SXLoadingTime];
                    }];
                } else {
                    LoginAndRegisterVC *vc = [[LoginAndRegisterVC alloc] init];
                    vc.hidesBottomBarWhenPushed = YES;
                    vc.pushType = 1;
                    [self.navigationController pushViewController:vc animated:YES];
                }
                
                return;
            }
            break;
            
        default:
            break;
    }
    //创建分享消息对象
    UMSocialMessageObject *messageObject = [UMSocialMessageObject messageObject];
    //创建网页内容对象
    NSString *thumbURL = [NSString stringWithFormat:@"%@", self.shareDataModel.imgPath[0]];
    UMShareWebpageObject *shareObject = [UMShareWebpageObject shareObjectWithTitle:[NSString stringWithFormat:@"%@", self.shareDataModel.fromName] descr:[NSString stringWithFormat:@"%@", self.shareDataModel.title] thumImage:thumbURL];
    //设置网页地址
    shareObject.webpageUrl = [NSString stringWithFormat:@"%@", self.shareDataModel.linkPath];
    //分享消息对象设置分享内容对象
    messageObject.shareObject = shareObject;
    //调用分享接口
    [[UMSocialManager defaultManager] shareToPlatform:platformType messageObject:messageObject currentViewController:self completion:^(id data, NSError *error) {
        if (error) {
            UMSocialLogInfo(@"************分享失败 %@*********",error);
        } else {
            if ([data isKindOfClass:[UMSocialShareResponse class]]) {
                UMSocialShareResponse *resp = data;
                //分享结果消息
                UMSocialLogInfo(@"响应消息 %@",resp.message);
                //第三方原始返回的数据
                UMSocialLogInfo(@"原始响应数据 %@",resp.originalResponse);
            } else {
                UMSocialLogInfo(@"响应数据 %@",data);
            }
        }
    }];
}

- (void)tapRemoveShareView:(UITapGestureRecognizer *)tap {
    [self removeShareView];
}

- (void)removeShareView {
    UIWindow *window = [[UIApplication sharedApplication] keyWindow];
    UIView *view0 = [window viewWithTag:9998];
    UIView *view1 = [window viewWithTag:9999];
    
    [view0 removeFromSuperview];
    [view1 removeFromSuperview];
}
#pragma mark --UITableView代理


- (void)scrollViewDidScroll:(UIScrollView *)scrollView {

    CGFloat navHeight = kNavBarAndStatusBarHeight + 20;
    CGFloat offset = scrollView.contentOffset.y;
    
    if (offset <= navHeight) {
        self.topNavView.backgroundColor = [UIColor clearColor];
        [self.navBackBtn setImage:ImageNamed(@"navigationBar_popBack") forState:UIControlStateNormal];
        self.navTitle.textColor = [UIColor whiteColor];
    } else {
        self.topNavView.backgroundColor = [UIColor whiteColor];
        [self.navBackBtn setImage:ImageNamed(@"enter") forState:UIControlStateNormal];
        self.navTitle.textColor = [UIColor blackColor];
    }
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    //刷新数据处理
    self.tableView.mj_footer.hidden = (self.tableViewDataArr.count == 0);
    if (self.tableViewDataArr.count == self.totalCount) {
        [self.tableView.mj_footer endRefreshingWithNoMoreData];
    } else {
        [self.tableView.mj_footer endRefreshing];
    }
    
    return self.tableViewDataArr.count;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
    
    ListNightSHTweetModel *model = self.tableViewDataArr[indexPath.row];
    /**
     1一张图 2三张图 3视频
     */
    if (model.cssType == 3) {
        MPMoviePlayerVC *vc = [[MPMoviePlayerVC alloc] init];
        vc.videoTitle = model.title;
        vc.videoPath = model.videoPath;
        vc.fromName = model.fromName;
        vc.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:vc animated:YES];
    } else {
        WKWebViewController *webVC = [[WKWebViewController alloc] initWithURLString:model.linkPath];
        webVC.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:webVC animated:YES];
    }
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    ListNightSHTweetModel *model = self.tableViewDataArr[indexPath.row];
    /**
     1一张图 2三张图 3视频
     */
    switch (model.cssType) {
        case 1:{//一张小图
            static NSString *CellIdentifier = CellID_PublicRightImageCell;
            PublicRightImageCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
            if (cell == nil) {
                cell = [[PublicRightImageCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
            }
            cell.shareBtn.tag = 1000 + indexPath.row;
            [cell.shareBtn addTarget:self action:@selector(shareAction:) forControlEvents:UIControlEventTouchUpInside];
            [cell updatePublicRightImageCellWithModel:model];
            return cell;
        }
            break;
        case 2:{//三张小图
            static NSString *CellIdentifier = CellID_PublicThreeImageCell;
            PublicThreeImageCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
            if (cell == nil) {
                cell = [[PublicThreeImageCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
            }
            cell.shareBtn.tag = 1000 + indexPath.row;
            [cell.shareBtn addTarget:self action:@selector(shareAction:) forControlEvents:UIControlEventTouchUpInside];
            [cell updatePublicThreeImageCellWithModel:model];
            return cell;
        }
            break;
        case 3:{//视频
            static NSString *CellIdentifier = CellID_DiscoverTableViewCell;
            DiscoverTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
            if (cell == nil) {
                cell = [[DiscoverTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
            }
            cell.imageVideo.hidden = NO;
            cell.shareBtn.tag = 1000 + indexPath.row;
            [cell.shareBtn addTarget:self action:@selector(shareAction:) forControlEvents:UIControlEventTouchUpInside];
            [cell updateDiscoverTableViewCellWithModel:model];
            return cell;
        }
            break;
        case 4: {//一张大图
            static NSString *CellIdentifier = CellID_DiscoverTableViewCell;
            DiscoverTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
            if (cell == nil) {
                cell = [[DiscoverTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
            }
            cell.imageVideo.hidden = YES;
            cell.shareBtn.tag = 1000 + indexPath.row;
            [cell.shareBtn addTarget:self action:@selector(shareAction:) forControlEvents:UIControlEventTouchUpInside];
            [cell updateDiscoverTableViewCellWithModel:model];
            return cell;
        }
            break;
        default:{//一张大图
            static NSString *CellIdentifier = CellID_DiscoverTableViewCell;
            DiscoverTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
            if (cell == nil) {
                cell = [[DiscoverTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
            }
            cell.imageVideo.hidden = YES;
            cell.shareBtn.tag = 1000 + indexPath.row;
            [cell.shareBtn addTarget:self action:@selector(shareAction:) forControlEvents:UIControlEventTouchUpInside];
            [cell updateDiscoverTableViewCellWithModel:model];
            return cell;
        }
            break;
    }
}

#pragma mark - 懒加载
- (UITableView *)tableView {
    if (!_tableView) {
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT) style:UITableViewStylePlain];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        [_tableView registerNib:[UINib nibWithNibName:@"DiscoverTableViewCell" bundle:nil] forCellReuseIdentifier:CellID_DiscoverTableViewCell];
        [_tableView registerNib:[UINib nibWithNibName:@"PublicRightImageCell" bundle:nil] forCellReuseIdentifier:CellID_PublicRightImageCell];
        [_tableView registerNib:[UINib nibWithNibName:@"PublicThreeImageCell" bundle:nil] forCellReuseIdentifier:CellID_PublicThreeImageCell];
    }
    return _tableView;
}


- (NSMutableArray *)tableViewDataArr {
    if (!_tableViewDataArr) {
        _tableViewDataArr = [[NSMutableArray alloc] init];
    }
    return _tableViewDataArr;
}

- (NSMutableArray *)listNightSHImgArr {
    if (!_listNightSHImgArr) {
        _listNightSHImgArr = [[NSMutableArray alloc] init];
    }
    return _listNightSHImgArr;
}

- (NSMutableArray *)listNightSHSpecialArr {
    if (!_listNightSHSpecialArr) {
        _listNightSHSpecialArr = [[NSMutableArray alloc] init];
    }
    return _listNightSHSpecialArr;
}

- (UIView *)tableHeaderView {
    if (!_tableHeaderView) {
        _tableHeaderView = [[UIView alloc] init];
        
        [_tableHeaderView addSubview:self.topView];
        [_tableHeaderView addSubview:self.fiveBtnView];
        
        [_tableHeaderView addSubview:self.mapView];
        [_tableHeaderView addSubview:self.scrollView];
        
        UILabel *lb = [[UILabel alloc] initWithFrame:CGRectMake(16, ADAPT_W(24) + GetViewYH(self.scrollView), SCREEN_WIDTH - 32, ADAPT_W(31))];
        lb.text = @"遇见夜上海";
        lb.font = FONT_BOLD(22);
        [_tableHeaderView addSubview:lb];
        
        _tableHeaderView.frame = CGRectMake(0, 0, SCREEN_WIDTH, GetViewYH(lb));
 
    }
    return _tableHeaderView;
}

- (FiveBtnView *)fiveBtnView {
    if (!_fiveBtnView) {
        _fiveBtnView = [[FiveBtnView alloc] initWithFrame:CGRectMake(0, GetViewYH(self.topView) + 18, SCREEN_WIDTH, SCREEN_WIDTH * 344.f/375.f)];
        
        WeakSelf;
        _fiveBtnView.clickRedeemBlock = ^(UIButton * _Nonnull sender) {
            StrongSelf;
            if ([sender.titleLabel.text isEqualToString:@"更多"]) {
                FiveBtnMoreViewController *vc = [[FiveBtnMoreViewController alloc] init];
                vc.title = @"夜上海专线";
                vc.type = @"夜上海";
                [strongSelf.navigationController pushViewController:vc animated:YES];
            } else {
                NSDictionary *dic = strongSelf.listNightSHImgArr[sender.tag - 40];
                if ([WXApi isWXAppInstalled]) {
                    WXLaunchMiniProgramReq *launchMiniProgramReq = [WXLaunchMiniProgramReq object];
                    launchMiniProgramReq.userName = dic[@"appId"];  //拉起的小程序的username-原始ID
                    launchMiniProgramReq.path = dic[@"appPath"];    //拉起小程序页面的可带参路径，不填默认拉起小程序首页
                    launchMiniProgramReq.miniProgramType = WXMiniProgramTypeRelease; //拉起小程序的类型
                    [WXApi sendReq:launchMiniProgramReq completion:^(BOOL success) {
                        
                    }];
                } else {
                    [SXLoadingView showAlertHUD:@"您还未安装微信~请先下载安装哦" duration:SXLoadingTime];
                }
            }
        };
    }
    return _fiveBtnView;
}

- (UIView *)mapView {
    if (!_mapView) {
        _mapView = [[UIView alloc] initWithFrame:CGRectMake(0, GetViewYH(self.fiveBtnView), SCREEN_WIDTH, 127)];
        UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 10)];
        view.backgroundColor = UIColorFromRGB(0xF8F8F8);
        [_mapView addSubview:view];
        
        UIButton *btnMap = [[UIButton alloc] initWithFrame:CGRectMake(16, 18, SCREEN_WIDTH - 32, 99)];
        [btnMap setImage:ImageNamed(@"编组11") forState:UIControlStateNormal];
        [_mapView addSubview:btnMap];
    }
    return _mapView;
}

- (ShanghaiNightsScrollView *)scrollView {
    if (!_scrollView) {
        _scrollView = [[ShanghaiNightsScrollView alloc] initWithFrame:CGRectMake(0, GetViewYH(self.mapView), SCREEN_WIDTH, ADAPT_W(392))];
        
        WeakSelf;
        _scrollView.block = ^(UIButton * _Nonnull btn, NSString * _Nonnull url) {
            StrongSelf;
            WKWebViewController *webVC = [[WKWebViewController alloc] initWithURLString:url];
            [strongSelf.navigationController pushViewController:webVC animated:YES];
        };
    }
    return _scrollView;
}

@end
